package com.xqit.ydzhkt.login.controller;

import com.xqit.ydzhkt.api.LoginApi;
import com.xqit.ydzhkt.entity.User;
import com.xqit.ydzhkt.login.service.LoginService;
import com.xqit.ydzhkt.common.response.HttpResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author admin
 * @time Janus on 2020/5/20
 */
@RestController
@CrossOrigin
public class LoginController implements LoginApi {



    @Autowired
    private LoginService loginService;

    //登录
    @PostMapping( value = "/login", produces = "application/json;charset=utf-8" )
    public HttpResult login(@RequestParam(value = "username")String username,
                            @RequestParam(value = "password")String password,
                            @RequestParam(value = "code")String code){

        //参数判空
        if (username == null || "".equals(username) ||
            password == null || "".equals(password) ||
            code == null || "".equals(code)){

            return HttpResult.success("用户名,密码,微信code不能为空");
        }

        HttpResult httpResult = loginService.login(username, password, code);
        return httpResult;
    }


}
